package HibernateBeans;
import org.hibernate.*;

import java.sql.Date;
import java.text.SimpleDateFormat;
import org.hibernate.cfg.*;
public class TestHibernate {
public static void main(String[] args)
{
	try
	{
		SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
		Session session=sessionFactory.getCurrentSession();
		Transaction tx=session.beginTransaction();
		System.out.println("1");
		Users user1 = new Users("ubua","a");
		System.out.println("constructor of user called");
		CustomerDetails obj1=new CustomerDetails("bhuyhuj","a","a","a","a","a","a","a","a","a","a","a");
//		obj1.setUser(user1);
		System.out.println("constructor of customerdetails called");
		System.out.println("" +
				"Entry inserted");
		RepDetails obj2 = new RepDetails("a","a","a","a","a");
//		System.out.println("user name of inserted entry is: "+obj1.getUser_name());
		Date dNow=new Date(1,1,1);
		SimpleDateFormat ft = 
		      new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
		//Customer_Products obj3=new Customer_Products(1,"a","a",new java.sql.Date(dNow.getTime()),2);
		
		Invoice obj4 = new Invoice(new java.sql.Date(dNow.getTime()), new java.sql.Date(dNow.getTime()),
				999);
		System.out.println("Invoice due date: "+obj4.getBill_date());
//		session.save(obj1);
//		session.save(obj2);
//		session.save(obj3);
		session.save(obj4);
		tx.commit();
		session.close();
	}
	catch(Exception e)
	{
		System.out.println("System"+e);
	}
}
}
